<?php 
error_reporting(0);
function noHTML($content) 
{ 

  $content = preg_replace("/<a[^>]*>/i",'', $content);    
  $content = preg_replace("/<\/a>/i", '', $content);     
  $content = preg_replace("/<div[^>]*>/i",'', $content);    
  $content = preg_replace("/<\/div>/i",'', $content); 
  $content = preg_replace("/<font[^>]*>/i",'', $content);    
  $content = preg_replace("/<\/font>/i",'', $content); 
  $content = preg_replace("/<p[^>]*>/i",'', $content);    
  $content = preg_replace("/<\/p>/i",'', $content); 
  $content = preg_replace("/<span[^>]*>/i",'', $content);    
  $content = preg_replace("/<\/span>/i",'', $content); 
  $content = preg_replace("/<\?xml[^>]*>/i",'', $content); 
  $content = preg_replace("/<\/\?xml>/i",'', $content); 
  $content = preg_replace("/<o:p[^>]*>/i",'', $content); 
  $content = preg_replace("/<\/o:p>/i",'', $content); 
  $content = preg_replace("/<u[^>]*>/i",'', $content); 
  $content = preg_replace("/<\/u>/i",'', $content); 
  $content = preg_replace("/<b[^>]*>/i",'', $content); 
  $content = preg_replace("/<\/b>/i",'', $content);  
  $content = preg_replace("/<meta[^>]*>/i",'', $content); 
  $content = preg_replace("/<\/meta>/i",'', $content); 
  $content = preg_replace("/<!--[^>]*-->/i",'', $content);
  $content = preg_replace("/<p[^>]*-->/i",'', $content);
  $content = preg_replace("/style=.+?['|\"]/i",'',$content);
  $content = preg_replace("/class=.+?['|\"]/i",'',$content);
  $content = preg_replace("/id=.+?['|\"]/i",'',$content);
  $content = preg_replace("/lang=.+?['|\"]/i",'',$content);
  $content = preg_replace("/width=.+?['|\"]/i",'',$content);
  $content = preg_replace("/height=.+?['|\"]/i",'',$content);
  $content = preg_replace("/border=.+?['|\"]/i",'',$content);   
  $content = preg_replace("/face=.+?['|\"]/i",'',$content);
  $content = preg_replace("/face=.+?['|\"]/",'',$content); 
  $content = preg_replace("/face=.+?['|\"]/",'',$content); 
  $content=str_replace( "&nbsp;","",$content); 
  return $content; 

    }
//get the q parameter from URL 
$q=$_GET["q"]; 
 
//find out which feed was selected 
if($q=="DemonSpider") 
 { 
 $xml=("http://www.dawner.info/?feed=rss2"); 
 } 
elseif($q=="aqniu")
 { 
 $xml=("http://www.aqniu.com/feed"); 
 }  
elseif($q=="Freebuf")
{
$xml=("http://www.freebuf.com/feed");
}
$xmlDoc = new DOMDocument(); 
$xmlDoc->load($xml); 
 
//get elements from "<channel>" 
$channel=$xmlDoc->getElementsByTagName('channel')->item(0); 
$channel_title = $channel->getElementsByTagName('title') 
->item(0)->childNodes->item(0)->nodeValue; 
$channel_link = $channel->getElementsByTagName('link') 
->item(0)->childNodes->item(0)->nodeValue; 
$channel_desc = $channel->getElementsByTagName('description') 
->item(0)->childNodes->item(0)->nodeValue; 
 
//output elements from "<channel>" 
echo ('<table class="table"><caption>');

echo("<b><a href='" . $channel_link 
 . "'>" . $channel_title . "</a></b></caption>"); 

echo '<thead> <tr> <th>文章标题</th><th>文章概述</th></tr> </thead> <tbody>';

//get and output "<item>" elements 
$x=$xmlDoc->getElementsByTagName('item'); 
for ($i=0; $i<=6; $i++) 
 { 
 $item_title=$x->item($i)->getElementsByTagName('title') 
 ->item(0)->childNodes->item(0)->nodeValue; 
 $item_link=$x->item($i)->getElementsByTagName('link') 
 ->item(0)->childNodes->item(0)->nodeValue; 
 $item_desc=$x->item($i)->getElementsByTagName('description') 
 ->item(0)->childNodes->item(0)->nodeValue; 
  echo ("<tr class='success'><td> <a href='" . $item_link . "' target='_blank'>" . $item_title . "</a></td>"); 

 #$item_descs=iconv_substr($item_desc,0,20,'gbk');
$item_desc1=noHTML($item_desc);
if (mb_strlen($item_desc1) >160)
{
$item_desc1=substr($item_desc1,0,160).chr(0);
}
else
{
$item_desc1=substr($item_desc1,0,100).chr(0);
}
echo "<td><font color='#FF0000'>【".$item_desc1. "】</font></td>"; 


 } 
?> 
